<?php


class Sql
{
    private $fields = [];
    private $from = [];
    private $where = [];

    public function select($fields)
    {
        $this->fields = $fields;
        return $this;
    }

    public function from($table, $alias)
    {
        $this->from[] = $table . 'AS' . $alias;
        return $this;
    }

    public function where($where)
    {
        $this->where[] = $where;
        return $this;
    }

    public function __toString()
    {
        return sprintf('select %s from %s where %s', join(', ', $this->fields),join(', ', $this->from), join(', ', $this->where));
    }
}

(new Sql())->select('')->where('')->from('');